import Home from '@/pages/Home/home';
import Category from '@/pages/Category/category';
import Cart from '@/pages/Cart/cart';
import User from '@/pages/User/user';
import Layout from '@/pages/Layout/index';
import Search from '@/pages/Search';
import Login from '@/pages/Login';
import AuthRoute from '@/components/AuthRoute';
import SearchList from '@/pages/Search/List.js';
import ProductDetail from '@/pages/Product/Detail.js';
import Pay from '@/pages/Pay/index';
import Order from '@/pages/Order/index';
import NoFoundPage from '@/pages/404';
import { Navigate } from 'react-router-dom';

// eslint-disable-next-line import/no-anonymous-default-export
export default [
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/',
    element: <Layout />,
    // redirect: '/home',
    // element: <Navigate to='/home' />,
    children: [
      {
        index: true,     // 只需要在二级路由的位置去掉path，设置index属性为true
        // path: 'home',
        element: <Home />
      },
      {
        path: 'category',
        element: <Category />
      },
      {
        path: 'cart',
        element: <Cart />
      },
      {
        path: 'user',
        element: <User />
      }
    ]
  },
  {
    path: '/search',
    element: <Search />
  },
  {
    path: '/searchlist/goods/list',
    element: <SearchList />
  },
  {
    path: '/prodetail/:id',
    element: <ProductDetail />
    //2，params 传参 
    // 跳转时用 / 斜杠
    //navigate('Article/1001/jack')
    // 配置路由时要有占位符
    // path: '/Article/:id/:name'
    // 接收参数   hook 函数useParams  
    //  const params = useParams()
    //   const id = params.id
  },
  {
    // 结算台
    path: '/pay',
    element: <AuthRoute><Pay></Pay></AuthRoute>
  },
  {
    // 订单管理
    path: '/order',
    element: <AuthRoute><Order></Order></AuthRoute>
  },
  {
    // 404
    path: '*', element: <NoFoundPage />
  }
]